from django.urls import path

from apps.books import views
from apps.users.views import UserModelView

urlpatterns = [
    path('search/', views.MySearchView()),
    path('borrow/', views.BorrowAPIView.as_view()),
    path('return/', views.ReturnAPIView.as_view()),
]

from rest_framework.routers import DefaultRouter, SimpleRouter

# 可以处理视图的路由器
router = SimpleRouter()
# 向路由器中注册视图集
router.register(r'books', views.BookModelViewSet, basename='books')
router.register(r'categories', views.CategoryModelViewSet, basename='categories')
router.register(r'histories', views.HistoryModelViewSet, basename='histories')
router.register(r'users', UserModelView, basename='books')
router.register(r'getbooks', views.BookReadOnlyModelViewSet, basename='getbooks')
router.register(r'getHistories', views.ReadOnlyHistoryModelViewSet, basename='getHistories')


# 追加路由
urlpatterns += router.urls
